From 8bf7ad22e5d4e6d3e365fd81a7f183978cdc2fe5 Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Fri, 27 Apr 2018 13:38:33 -0600 Subject: [PATCH] update configure compatibility with system zlib, (#156) and minizip. restore support for building with configure outside the srcdir. --- GPSBabel.pro | 2 +- Makefile.in | 14 +++- config.h.in | 6 ++ configure | 120 ++++++++++++++++++++++++++++--- configure.ac | 31 +++++++- defs.h | 2 +- jeeps/Makefile.in | 0 shapelib/Makefile.in | 0 src/core/ziparchive.cc | 7 +- src/core/ziparchive.h | 5 ++ zlib/README.gpsbabel | 2 - zlib/contrib/minizip/zip.c | 2 +- zlib/contrib/minizip/zip.c.patch | 11 --- zlib/contrib/minizip/zip.h | 2 +- zlib/contrib/minizip/zip.h.patch | 11 --- zlib/empty.in | 0 16 files changed, 169 insertions(+), 46 deletions(-) delete mode 100644 jeeps/Makefile.in delete mode 100644 shapelib/Makefile.in delete mode 100644 zlib/contrib/minizip/zip.c.patch delete mode 100644 zlib/contrib/minizip/zip.h.patch delete mode 100644 zlib/empty.in diff --git a/GPSBabel.pro b/GPSBabel.pro index 35f212adc..c73807837 100644 --- a/GPSBabel.pro +++ b/GPSBabel.pro @@ -132,7 +132,7 @@ HEADERS = \ src/core/xmlstreamwriter.h \ src/core/logging.h -SUBDIRS += jeeps +INCLUDEPATH += zlib macx|linux { DEFINES += HAVE_NANOSLEEP HAVE_LIBUSB HAVE_GLOB diff --git a/Makefile.in b/Makefile.in index 5b792f46f..1edc25e7e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -10,6 +10,14 @@ srcdir = @srcdir@ VPATH = @srcdir@ +builddir = @builddir@ + +# when srcdir and builddir are different we need to get config.h from builddir. +ifeq ($(srcdir), $(builddir)) +BUILD_CPP = -I$(srcdir) +else +BUILD_CPP = -I$(builddir) -I$(srcdir) +endif # version and release are defined in the head of configure.ac # don't forget 'autoconf' if you change them @@ -49,7 +57,7 @@ LRELEASE=@LRELEASE@ #OPTIMIZATION=-O $(EXTRA_OPTIMIZATION) #DEBUGGING=-g $(EXTRA_DEBUGGING) # add -DDEBUG_MEM to turn on memory allocation logging -GBCFLAGS=$(EXTRA_CFLAGS) $(DEBUGGING) -I$(srcdir) @QT_INC_OPT@$(QT_INC) \ +GBCFLAGS=$(EXTRA_CFLAGS) $(DEBUGGING) $(BUILD_CPP) @ZLIB_CPP@ @QT_INC_OPT@$(QT_INC) \ $(OPTIMIZATION) -DHAVE_CONFIG_H -DNEW_STRINGS LDFLAGS=$(EXTRA_LDFLAGS) @LDFLAGS@ PREFIX=@prefix@ @@ -106,7 +114,7 @@ MINIZIP=zlib/contrib/minizip/zip.o \ ZLIB=zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/inffast.o \ zlib/inflate.o zlib/infback.o zlib/inftrees.o zlib/trees.o \ zlib/uncompr.o zlib/gzlib.o zlib/gzclose.o zlib/gzread.o \ - zlib/gzwrite.o zlib/zutil.o $(MINIZIP) + zlib/gzwrite.o zlib/zutil.o LIBOBJS = queue.o route.o waypt.o filter_vecs.o util.o vecs.o mkshort.o \ @@ -117,7 +125,7 @@ LIBOBJS = queue.o route.o waypt.o filter_vecs.o util.o vecs.o mkshort.o \ src/core/xmlstreamwriter.o \ src/core/usasciicodec.o\ src/core/ziparchive.o \ - $(GARMIN) $(JEEPS) $(SHAPE) @ZLIB@ $(FMTS) $(FILTERS) + $(GARMIN) $(JEEPS) $(SHAPE) @ZLIB@ @MINIZIP@ $(FMTS) $(FILTERS) OBJS = main.o globals.o $(LIBOBJS) @FILEINFO@ DEPFILES = $(OBJS:.o=.d) diff --git a/config.h.in b/config.h.in index f669911cf..f553d8520 100644 --- a/config.h.in +++ b/config.h.in @@ -21,6 +21,9 @@ /* Define to 1 if you have the `m' library (-lm). */ #undef HAVE_LIBM +/* Define to 1 if you have the `minizip' library (-lminizip). */ +#undef HAVE_LIBMINIZIP + /* Defined if you have libusb */ #undef HAVE_LIBUSB @@ -72,6 +75,9 @@ /* 1 to enable as many formats as possible */ #undef MAXIMAL_ENABLED +/* 1 to inhibit our use of libminizip. */ +#undef MINIZIP_INHIBITED + /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT diff --git a/configure b/configure index bfd4f1548..c11660331 100755 --- a/configure +++ b/configure @@ -628,7 +628,6 @@ QT_INC DOCDIR INSTALL_DEBUG GPSBABEL_DEBUG -ZLIB GBSER OSJEEPS USB_CFLAGS @@ -642,6 +641,9 @@ ac_ct_QMAKE QMAKE RC FILEINFO +MINIZIP +ZLIB +ZLIB_CPP FMTS EGREP GREP @@ -698,6 +700,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -725,6 +728,7 @@ enable_csv enable_most enable_filters with_zlib +with_libminizip with_doc ' ac_precious_vars='build_alias @@ -777,6 +781,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1029,6 +1034,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1166,7 +1180,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1319,6 +1333,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -1363,6 +1378,8 @@ Optional Packages: --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-zlib=(included)|system|no + --with-libminizip=(included)|system|no + --with-doc=DIR Path where the documentation will be stored. Some influential environment variables: @@ -5354,12 +5371,89 @@ $as_echo "no" >&6; } ;; #( *) : + ZLIB_CPP="-I\$(srcdir)/zlib" ZLIB="\$(ZLIB)" { $as_echo "$as_me:${as_lineno-$LINENO}: result: using included version" >&5 $as_echo "using included version" >&6; } ;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support zlib's minizip" >&5 +$as_echo_n "checking whether to support zlib's minizip... " >&6; } + +# Check whether --with-libminizip was given. +if test "${with_libminizip+set}" = set; then : + withval=$with_libminizip; +fi + +case $with_libminizip in #( + "system") : + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zipOpen64 in -lminizip" >&5 +$as_echo_n "checking for zipOpen64 in -lminizip... " >&6; } +if ${ac_cv_lib_minizip_zipOpen64+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lminizip $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char zipOpen64 (); +int +main () +{ +return zipOpen64 (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_minizip_zipOpen64=yes +else + ac_cv_lib_minizip_zipOpen64=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_minizip_zipOpen64" >&5 +$as_echo "$ac_cv_lib_minizip_zipOpen64" >&6; } +if test "x$ac_cv_lib_minizip_zipOpen64" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBMINIZIP 1 +_ACEOF + + LIBS="-lminizip $LIBS" + +fi + + ;; #( + "no") : + + +$as_echo "#define MINIZIP_INHIBITED 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + ;; #( + *) : + + MINIZIP="\$(MINIZIP)" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: using included version" >&5 +$as_echo "using included version" >&6; } + ;; +esac + + case "$target" in #( *-*-mingw32*) : @@ -5982,7 +6076,6 @@ esac - case "$target" in #( *-linux-*) : @@ -6097,12 +6190,13 @@ $as_echo "$DOCDIR" >&6; } # AC_CHECK_HEADERS([fcntl.h inttypes.h libintl.h limits.h malloc.h stddef.h stdint.h stdlib.h string.h strings.h sys/ioctl.h sys/time.h termios.h unistd.h]) # set up HAVE_STDARG_H for zlib. -for ac_header in stdarg.h +for ac_header in unistd.h stdarg.h do : - ac_fn_cxx_check_header_mongrel "$LINENO" "stdarg.h" "ac_cv_header_stdarg_h" "$ac_includes_default" -if test "x$ac_cv_header_stdarg_h" = xyes; then : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF -#define HAVE_STDARG_H 1 +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -6150,7 +6244,14 @@ done -ac_config_files="$ac_config_files Makefile gbversion.h gui/setup.iss xmldoc/makedoc tools/mkcapabilities win32/gpsbabel.rc jeeps/Makefile shapelib/Makefile zlib/empty" +# make sure subdirectoires exist to receive object files. +# they may not exist if we are compiling outside the src tree. +as_dir=jeeps; as_fn_mkdir_p +as_dir=shapelib; as_fn_mkdir_p +as_dir=src/core; as_fn_mkdir_p +as_dir=zlib/contrib/minizip; as_fn_mkdir_p + +ac_config_files="$ac_config_files Makefile gbversion.h gui/setup.iss xmldoc/makedoc tools/mkcapabilities win32/gpsbabel.rc" ac_config_files="$ac_config_files gui/makelinuxdist.sh" @@ -6852,9 +6953,6 @@ do "xmldoc/makedoc") CONFIG_FILES="$CONFIG_FILES xmldoc/makedoc" ;; "tools/mkcapabilities") CONFIG_FILES="$CONFIG_FILES tools/mkcapabilities" ;; "win32/gpsbabel.rc") CONFIG_FILES="$CONFIG_FILES win32/gpsbabel.rc" ;; - "jeeps/Makefile") CONFIG_FILES="$CONFIG_FILES jeeps/Makefile" ;; - "shapelib/Makefile") CONFIG_FILES="$CONFIG_FILES shapelib/Makefile" ;; - "zlib/empty") CONFIG_FILES="$CONFIG_FILES zlib/empty" ;; "gui/makelinuxdist.sh") CONFIG_FILES="$CONFIG_FILES gui/makelinuxdist.sh" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; diff --git a/configure.ac b/configure.ac index bfa5f6609..0a49f627a 100644 --- a/configure.ac +++ b/configure.ac @@ -121,9 +121,28 @@ AS_CASE([$with_zlib], ["system"], [ AC_DEFINE(ZLIB_INHIBITED, 1, [1 to inhibit our use of zlib.]) AC_MSG_RESULT([no]) ], [ + ZLIB_CPP="-I\$(srcdir)/zlib" ZLIB="\$(ZLIB)" AC_MSG_RESULT([using included version]) ]) +AC_SUBST(ZLIB_CPP) +AC_SUBST(ZLIB) + +AC_MSG_CHECKING([whether to support zlib's minizip]) +AC_ARG_WITH([libminizip], + [AS_HELP_STRING( + [--with-libminizip=(included)|system|no], + [])]) +AS_CASE([$with_libminizip], ["system"], [ + AC_CHECK_LIB([minizip], [zipOpen64]) +], ["no"], [ + AC_DEFINE(MINIZIP_INHIBITED, 1, [1 to inhibit our use of libminizip.]) + AC_MSG_RESULT([no]) +], [ + MINIZIP="\$(MINIZIP)" + AC_MSG_RESULT([using included version]) +]) +AC_SUBST(MINIZIP) AS_CASE(["$target"], [*-*-mingw32*], [ FILEINFO=fileinfo.o @@ -265,7 +284,6 @@ AC_SUBST(USB_LIBS) AC_SUBST(USB_CFLAGS) AC_SUBST(OSJEEPS) AC_SUBST(GBSER) -AC_SUBST(ZLIB) dnl Linux HID support AS_CASE(["$target"], [*-linux-*], [ @@ -336,7 +354,7 @@ AC_MSG_RESULT([$DOCDIR]) # AC_CHECK_HEADERS([fcntl.h inttypes.h libintl.h limits.h malloc.h stddef.h stdint.h stdlib.h string.h strings.h sys/ioctl.h sys/time.h termios.h unistd.h]) # set up HAVE_STDARG_H for zlib. -AC_CHECK_HEADERS([stdarg.h]) +AC_CHECK_HEADERS([unistd.h stdarg.h]) # Checks for typedefs, structures, and compiler characteristics. # AC_C_CONST @@ -367,6 +385,13 @@ AC_SUBST(QT_INC_OPT) AC_SUBST(QT_SYSINC_OPT) AC_SUBST(QT_LIBS) -AC_CONFIG_FILES([Makefile gbversion.h gui/setup.iss xmldoc/makedoc tools/mkcapabilities win32/gpsbabel.rc jeeps/Makefile shapelib/Makefile zlib/empty]) +# make sure subdirectoires exist to receive object files. +# they may not exist if we are compiling outside the src tree. +AS_MKDIR_P([jeeps]) +AS_MKDIR_P([shapelib]) +AS_MKDIR_P([src/core]) +AS_MKDIR_P([zlib/contrib/minizip]) + +AC_CONFIG_FILES([Makefile gbversion.h gui/setup.iss xmldoc/makedoc tools/mkcapabilities win32/gpsbabel.rc]) AC_CONFIG_FILES([gui/makelinuxdist.sh], [chmod +x gui/makelinuxdist.sh]) AC_OUTPUT diff --git a/defs.h b/defs.h index ea2bc0ac5..98e025f16 100644 --- a/defs.h +++ b/defs.h @@ -28,7 +28,7 @@ #if HAVE_LIBZ #include #elif !ZLIB_INHIBITED -#include "zlib/zlib.h" +#include "zlib.h" #endif #include "gbfile.h" #include "inifile.h" diff --git a/jeeps/Makefile.in b/jeeps/Makefile.in deleted file mode 100644 index e69de29bb..000000000 diff --git a/shapelib/Makefile.in b/shapelib/Makefile.in deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/core/ziparchive.cc b/src/core/ziparchive.cc index d4b5dcacc..947444505 100644 --- a/src/core/ziparchive.cc +++ b/src/core/ziparchive.cc @@ -23,7 +23,11 @@ #include "defs.h" #include "src/core/logging.h" +#ifdef HAVE_LIBMINIZIP +#include +#else #include "zlib/contrib/minizip/zip.h" +#endif #include #include @@ -89,4 +93,5 @@ bool ZipArchive::Add(QStringList items_to_add) { return true; } return false; -} \ No newline at end of file +} + diff --git a/src/core/ziparchive.h b/src/core/ziparchive.h index 0c9f8f27b..e91da17e2 100644 --- a/src/core/ziparchive.h +++ b/src/core/ziparchive.h @@ -21,7 +21,12 @@ #include #include +#include "defs.h" +#ifdef HAVE_LIBMINIZIP +#include +#else #include "zlib/contrib/minizip/zip.h" +#endif class ZipArchive { diff --git a/zlib/README.gpsbabel b/zlib/README.gpsbabel index 21a5dd79c..1f9e687a3 100644 --- a/zlib/README.gpsbabel +++ b/zlib/README.gpsbabel @@ -4,6 +4,4 @@ other changes after zlib 1.2.8 may be required as well. 1. zconf.h is modified to include our config.h 2. contrib/minizip/ioapi.c modifies a conditional adding __CYGWIN__ 3. contrib/minizip/ioapi.h modifies a conditional adding __FreeBSD__ -4. contrib/minizip/zip.c changes the path to find our zlib.h -5. contrib/minizip/zip.h changes the path to find our zlib.h See the corresponding .patch files. diff --git a/zlib/contrib/minizip/zip.c b/zlib/contrib/minizip/zip.c index 1b72b943d..44e88a9cb 100644 --- a/zlib/contrib/minizip/zip.c +++ b/zlib/contrib/minizip/zip.c @@ -26,7 +26,7 @@ #include #include #include -#include "../../zlib.h" // GPSBabel-local to get the "right" one. +#include "zlib.h" #include "zip.h" #ifdef STDC diff --git a/zlib/contrib/minizip/zip.c.patch b/zlib/contrib/minizip/zip.c.patch deleted file mode 100644 index 3f1eb82ef..000000000 --- a/zlib/contrib/minizip/zip.c.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- ../zlib-1.2.8/contrib/minizip/zip.c 2013-02-24 00:32:30.000000000 -0700 -+++ zlib/contrib/minizip/zip.c 2017-11-11 09:05:50.662012999 -0700 -@@ -26,7 +26,7 @@ - #include - #include - #include --#include "zlib.h" -+#include "../../zlib.h" // GPSBabel-local to get the "right" one. - #include "zip.h" - - #ifdef STDC diff --git a/zlib/contrib/minizip/zip.h b/zlib/contrib/minizip/zip.h index 1664dc08d..8aaebb623 100644 --- a/zlib/contrib/minizip/zip.h +++ b/zlib/contrib/minizip/zip.h @@ -47,7 +47,7 @@ extern "C" { //#define HAVE_BZIP2 #ifndef _ZLIB_H -#include "../../zlib.h" +#include "zlib.h" #endif #ifndef _ZLIBIOAPI_H diff --git a/zlib/contrib/minizip/zip.h.patch b/zlib/contrib/minizip/zip.h.patch deleted file mode 100644 index 031b0b27d..000000000 --- a/zlib/contrib/minizip/zip.h.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- ../zlib-1.2.8/contrib/minizip/zip.h 2010-02-15 04:58:22.000000000 -0700 -+++ zlib/contrib/minizip/zip.h 2017-11-11 09:05:50.662012999 -0700 -@@ -47,7 +47,7 @@ - //#define HAVE_BZIP2 - - #ifndef _ZLIB_H --#include "zlib.h" -+#include "../../zlib.h" - #endif - - #ifndef _ZLIBIOAPI_H diff --git a/zlib/empty.in b/zlib/empty.in deleted file mode 100644 index e69de29bb..000000000 -- 2.30.2